package net.towee.client.com.stuff.view;

import net.towee.client.com.stuff.presenter.StuffPresenter.Display;
import net.towee.client.i18n.ToweeConstants;
import net.towee.client.resources.ClientResource;
import net.towee.client.widgets.LeftTabsWidget;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.inject.Inject;

public class StuffView extends FlowPanel implements Display {
	protected final ToweeConstants constants;
	protected final ClientResource resource;

	protected FlowPanel container;
	private HasClickHandlers finderTab;
	private HasClickHandlers creatorTab;

	@Inject
	public StuffView(ToweeConstants constants, ClientResource resource) {
		this.constants = constants;
		this.resource = resource;
		
		this.setStyleName( resource.css().stuff() );

		createTabs();
		createContainer();
	}

	/**
	 * Build columns
	 */
	private void createContainer() {
		// Create columns container
		container = new FlowPanel();
		container.getElement().getStyle().setProperty("left", "280px");
		container.getElement().getStyle().setProperty("right", "0px");
		container.getElement().getStyle().setProperty("top", "0px");
		container.getElement().getStyle().setProperty("bottom", "0px");
		container.getElement().getStyle().setProperty("position", "absolute");
		
		// Add container
		add(container);
	}

	/**
	 * Build find/create changer
	 */
	private void createTabs() {
		// Create tabs container
		LeftTabsWidget tabs = new LeftTabsWidget( resource );
		tabs.getElement().getStyle().setProperty("top", "5px");
		tabs.getElement().getStyle().setProperty("width", "225px");
		add(tabs);
		
		// Add tabs
		finderTab = (HasClickHandlers) tabs.addTab(constants.lobbyGroupsFinder(), true);
		creatorTab = (HasClickHandlers) tabs.addTab(constants.lobbyGroupsCreator());
	}

	@Override
	public HasClickHandlers getFinderTab() {
		return finderTab;
	}

	@Override
	public HasClickHandlers getCreatorTab() {
		return creatorTab;
	}

	@Override
	public HasWidgets getTabContainer() {
		return container;
	}
}
